//
//  WXRoadHelpTableViewCell.m
//  CarJX
//
//  Created by xcq on 14-10-10.
//  Copyright (c) 2014年 KK. All rights reserved.
//

#import "WXRoadHelpTableViewCell.h"


@implementation WXRoadHelpTableViewCell

- (void)awakeFromNib
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [[NSUserDefaults standardUserDefaults]removeObjectForKey:@"seleted"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cellSeleted:) name:@"cellSeleted" object:nil];
}
- (void) cellSeleted:(NSNotification *)notification{

    _dic = [(NSMutableDictionary *)notification.object copy];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)enshrineAction:(id)sender {
    UIButton *butn = (UIButton *)sender;
    
     if ([[NSUserDefaults standardUserDefaults] objectForKey:@"seleted"] != nil) {
         int tag = [[[NSUserDefaults standardUserDefaults]objectForKey:@"seleted"] integerValue];
             if (tag == butn.tag) {
                return;
             }else{
                  [butn setImage:[UIImage imageNamed:@"19_3_4"] forState:UIControlStateNormal];
 /*
 //                _imageOne = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"19_3_4@2x"]];
//                _imageOne.tag = 101;
//                [_imageOne setFrame:(CGRect){ {10,10} , {18 , 18} }];
//                [butn addSubview:_imageOne];
             

//                [_imageOne removeFromSuperview];
//                _imageOne = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"19_3_4@2x"]];
//                _imageOne.tag = 101;
//                [_imageOne setFrame:(CGRect){ {10,10} , {18 , 18} }];
//                [butn addSubview:_imageOne];
//
  */
            }
            
#pragma mark -  删除点击得按钮
         UIButton *btn = (UIButton*)[_dic objectForKey:[NSString stringWithFormat:@"%d",tag]];
         NSLog(@"%@",btn);
         [btn setImage:[UIImage imageNamed:@"19_3_5"] forState:UIControlStateNormal];
         
             [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%d",_enshrineBtn.tag] forKey:@"seleted"];
             [[NSUserDefaults standardUserDefaults]synchronize];
             
         
    }else{
       
        [butn setImage:[UIImage imageNamed:@"19_3_4"] forState:UIControlStateNormal];

        [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%d",_enshrineBtn.tag] forKey:@"seleted"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        
       
    }
    NSInteger row = butn.tag % 600;
    NSLog(@"row :  %d"  ,  row);
    [[NSNotificationCenter defaultCenter] postNotificationName:@"seletedpuss" object:[NSString stringWithFormat:@"%d",row]];
    
}
@end
